package com.zzyweb.managementsystem.controller;

import com.zzyweb.managementsystem.pojo.Building;
import com.zzyweb.managementsystem.service.BuildingService;
import com.zzyweb.managementsystem.util.ResponseObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhiyi
 * @date 9/23/25
 **/
@RestController
@RequestMapping("/building")
@CrossOrigin
public class BuildingController {
    @Autowired
    BuildingService buildingService;
    @GetMapping("/all")
    public ResponseObject getAllBuildings() {
        return ResponseObject.ok(buildingService.getAllBuildings());
    }

    @PostMapping("/conditions")
    public ResponseObject getBuildingsByConditions(@RequestBody Building building) {
        List<Building> buildings = buildingService.getBuildingByConditions(building);
        return ResponseObject.ok(buildings);
    }
}
